package com.geovis.boot.exception.base;

import com.fasterxml.jackson.annotation.JsonInclude;

/**
 * 异常返回格式
 * Created by l.wang on 2018年8月21日
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ErrorResponse {

	private int code;
	private String desc;
	private long timestamp;
	
	public ErrorResponse() {}
	
	public static ErrorResponse of(int code, String desc) {
        ErrorResponse errorResponse = new ErrorResponse();
        errorResponse.code = code;
        errorResponse.desc = desc;
        errorResponse.timestamp = System.currentTimeMillis();
        return errorResponse;
    }
	 
	public ErrorResponse(int code, String desc) {
        super();
        this.code = code;
        this.desc = desc;
        this.timestamp = System.currentTimeMillis();
    }
	
	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public String getDesc() {
		return desc;
	}
	public void setDesc(String desc) {
		this.desc = desc;
	}
	public long getTimestamp() {
		return timestamp;
	}
	public void setTimestamp(long timestamp) {
		this.timestamp = timestamp;
	}
	
	@Override
    public String toString() {
        return "ErrorResponse{" +
                "code=" + code +
                ", desc='" + desc + '\'' +
                ", timestamp=" + timestamp +
                '}';
    }
	
}
